#include "Core.h"
#include "AsyncConnectHandler.h"
#include "SyncConnectEvent.h"

AsyncConnectHandler::AsyncConnectHandler(IMessageSystem::CallBack::OnConnectSuccess s,IMessageSystem::CallBack::OnConnectFailed f,void* ud)
{
	m_SuccessCallback = s;
	m_FailedCallback = f;
	m_pUserData = ud;
}

void AsyncConnectHandler::Success(IPumpService* svc)
{
	SyncConnectEvent* pEvent = MyNew SyncConnectEvent(m_SuccessCallback,m_FailedCallback,m_pUserData);
	pEvent->SetResult(true,svc);
	m_pManager->Push(pEvent);
}

void AsyncConnectHandler::Fail()
{
	SyncConnectEvent* pEvent = MyNew SyncConnectEvent(m_SuccessCallback,m_FailedCallback,m_pUserData);
	pEvent->SetResult(false,0);
	m_pManager->Push(pEvent);
}